package com.forevershine.business.context;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import com.cohesion.bootstrap.common.ICache;
import com.cohesion.bootstrap.common.MemoryCacheImpl;
import com.forevershine.business.persistent.ActionNotesDao;
import com.forevershine.business.persistent.BodyFabricDao;
import com.forevershine.business.persistent.BriefDao;
import com.forevershine.business.persistent.ConfigDao;
import com.forevershine.business.persistent.EmployeeDao;
import com.forevershine.business.persistent.IDataAccessor;
import com.forevershine.business.persistent.IndentBreakdownDao;
import com.forevershine.business.persistent.MySqlAccessor;
import com.forevershine.business.persistent.SampleNoteReportDao;
import com.forevershine.business.persistent.StyleDetailDao;
import com.forevershine.business.persistent.TaskDao;
import com.forevershine.business.persistent.TrimDao;
import com.forevershine.business.persistent.impl.ActionNotesDaoImpl;
import com.forevershine.business.persistent.impl.BodyFabricDaoImpl;
import com.forevershine.business.persistent.impl.BriefDaoImpl;
import com.forevershine.business.persistent.impl.ConfigDaoImpl;
import com.forevershine.business.persistent.impl.EmployeeDaoImpl;
import com.forevershine.business.persistent.impl.IndentBreakdownDaoImpl;
import com.forevershine.business.persistent.impl.SampleNoteReportDaoImpl;
import com.forevershine.business.persistent.impl.StyleDetailDaoImpl;
import com.forevershine.business.persistent.impl.TaskDaoImpl;
import com.forevershine.business.persistent.impl.TrimDaoImpl;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import com.google.inject.name.Names;

public class ContextModule extends AbstractModule{

	private static final String CONFIG_FILE="forevershine.guice.properties";
	
	@Override
	protected void configure() {
		
		Properties prop = new Properties();
		try {
			prop.load(ContextModule.class.getClassLoader().getResourceAsStream(CONFIG_FILE));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Names.bindProperties(binder(), prop);
		
		bind(IDataAccessor.class).to(MySqlAccessor.class).in(Scopes.SINGLETON);
		bind(BriefDao.class).to(BriefDaoImpl.class);
		bind(EmployeeDao.class).to(EmployeeDaoImpl.class);
		bind(TaskDao.class).to(TaskDaoImpl.class);
		bind(ConfigDao.class).to(ConfigDaoImpl.class);
		bind(BodyFabricDao.class).to(BodyFabricDaoImpl.class);
		bind(IndentBreakdownDao.class).to(IndentBreakdownDaoImpl.class);
		bind(TrimDao.class).to(TrimDaoImpl.class);
		bind(ActionNotesDao.class).to(ActionNotesDaoImpl.class);
		bind(StyleDetailDao.class).to(StyleDetailDaoImpl.class);
		bind(SampleNoteReportDao.class).to(SampleNoteReportDaoImpl.class);
				
	}

}
